﻿using System;
using System.Collections.ObjectModel;
using Microsoft.Practices.EnterpriseLibrary.Caching;

namespace SmartFront.Toolkit.ActionFramework
{
    /// <summary>
    /// This is class is used to setting the configuration options such as AutoRfresh, ExpirationPolicy,Scavenging etc.
    /// </summary>
    [Serializable]
    public class CacheOptions
    {
        #region Fields

        /// <summary>
        /// Gets or sets a value indicating whether this <see cref="CacheOptions"/> is enabled.
        /// </summary>
        /// <value><c>true</c> if enabled; otherwise, <c>false</c>.</value>
        public bool Enabled { get; set; }

        /// <summary>
        /// Gets or sets a value indicating whether this <see cref="CacheOptions"/> is ignore.
        /// </summary>
        /// <value><c>true</c> if ignore; otherwise, <c>false</c>.</value>
        public bool Ignore { get; set; }

        /// <summary>
        /// Gets or sets the expiration policy.
        /// </summary>
        /// <value>The expiration policy.</value>
        public Collection<ICacheItemExpiration> ExpirationPolicy { get; private set; }

        /// <summary>
        /// Gets or sets the scavenging priority.
        /// </summary>
        /// <value>The scavenging priority.</value>
        public CacheItemPriority ScavengingPriority { get; set; }

        /// <summary>
        /// Gets or sets a value indicating whether [auto refresh].
        /// </summary>
        /// <value><c>true</c> if [auto refresh]; otherwise, <c>false</c>.</value>
        public bool AutoRefresh { get; set; }

        #endregion

        #region Constructor

        /// <summary>
        /// Initializes a new instance of the <see cref="CacheOptions"/> class.
        /// </summary>
        public CacheOptions()
        {
            this.ExpirationPolicy = new Collection<ICacheItemExpiration>();
        }

        #endregion

        #region Public Methods

        /// <summary>
        /// Adds to expiration policy collection.
        /// </summary>
        /// <param name="expiration">The expiration.</param>
        public void AddToExpirationPolicyCollection(ICacheItemExpiration expiration)
        {
            this.ExpirationPolicy.Add(expiration);
        }

        #endregion
    }
}